package netnotifier.notification;

import netnotifier.NetNotifier;

public class UDPPacket extends Packet
{
	public int sourcePort=0;
	public int destinationPort=0;
	public int dataLength=0;
	public int checksum=0;

	public String type="unknown";
	
	public static String[] defaultFields= new String[]{"sourcePort", "destinationPort","dataLength","checksum","type"};
	
	public UDPPacket(byte[] rawData, int udpOffset, int udpLength)
	{
		sourcePort|=(rawData[udpOffset+0]&0xff);
		sourcePort<<=8;
		sourcePort|=(rawData[udpOffset+1]&0xff);
		
		destinationPort|=(rawData[udpOffset+2]&0xff);
		destinationPort<<=8;
		destinationPort|=(rawData[udpOffset+3]&0xff);
		
		dataLength|=(rawData[udpOffset+4]&0xff);
		dataLength<<=8;
		dataLength|=(rawData[udpOffset+5]&0xff);
		
		checksum|=(rawData[udpOffset+6]&0xff);
		checksum<<=8;
		checksum|=(rawData[udpOffset+7]&0xff);
		
		if(sourcePort==53)type="DNS";
		else if(destinationPort==53)type="DNS";
		else if(sourcePort==5353)type="MDNS";
		else if(destinationPort==5353)type="MDNS";
	}
}
